<template>
	<view>
		<view class="empty"></view>
		<view class="status_bar">
			<uni-icons type="left" size="24" @click="back"></uni-icons>
			<uni-icons type="more" size="24"></uni-icons>
		</view>
		
		<view class="QRCon">
			<view class="accountInfo">
				<image src="/static/icon_active/xiaoxi-zhihui.png"></image>
				<view>
					<view style="margin-bottom: 10px; font-size: 20px; font-weight: bold;">好男儿</view>
					<view style="color: gray;">中国 山西</view>
				</view>
			</view>
			<view class="QRCode">
				<img style="width: 300px; height: 300px;" :src="qrcode"></img>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				qrcode: 'data:image/jpeg;base64,'
			}
		},
		methods: {
			back() {
				uni.navigateBack()
			},
			getQrcode() {
				let userInfo = JSON.parse(uni.getStorageSync('login-user-info'))
				if (userInfo.username) {
					this.$http('/user/qrcode', 'get', {username: userInfo.username}).then(
						succ => {
							this.qrcode = this.qrcode + succ.data
						}
					)
				}
			}
		},
		onLoad() {
			this.getQrcode()
		}
	}
</script>

<style scoped lang="scss">
	.empty {
		height: var(--status-bar-height);
	}
	.status_bar {
		height: 45px;
		line-height: 45px;
		display: flex;
		justify-content: space-between;
		padding: 0 15px 0 8px;
	}
	
	.QRCon {
		height: 400px;
		width: 300px;
		margin-top: 40px;
		position: absolute;
		left: 50%;
		transform: translateX(-150px);
		& > .accountInfo {
			height: 100px;
			display: flex;
			& > image {
				width: 80px; 
				height: 80px; 
				background-color: #eeeeee;
			}
			
			& > view {
				height: 80px; 
				width: 150px; 
				display: flex; 
				flex-direction: column;
				justify-content: flex-end;
				margin-left: 8px;
			}
		}
		& > .QRCode {
			height: 300px;
		}
	}
</style>
